Date.prototype.formart = function () {
    var dt = this;
    var m = new Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Spt", "Oct", "Nov", "Dec");
    var w = new Array("Sunday","Monday", "Tuseday", "Wednesday", "Thursday", "Friday", "Saturday");
    var d = new Array("st", "nd", "rd", "th");
    mn = dt.getMonth();
    wn = dt.getDay();
    dn = dt.getDate();
    var dns;
    if (((dn) < 1) || ((dn) > 3)) {
        dns = d[3];
    } else {
        dns = d[(dn) - 1];
        if ((dn == 11) || (dn == 12)) {
            dns = d[3];
        }
    }
    return m[mn] + " " + dn + dns + " " + w[wn] + " " + dt.getFullYear();
}
Date.prototype.FormatDate = function(fmt) {
    var o = {
        "M+" : this.getMonth() + 1,
        "d+" : this.getDate(),
        "h+" : this.getHours(),
        "m+" : this.getMinutes(),
        "s+" : this.getSeconds(),
        "q+" : Math.floor((this.getMonth() + 3) / 3),
        "S" : this.getMilliseconds()
    };
    if (/(y+)/.test(fmt))
        fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
    for (var k in o)
    if (new RegExp("(" + k + ")").test(fmt))
        fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
    return fmt;
}